package repository

import "time"

//地区表相关
type Districts struct {
	Id           int32  `xorm:"id"`
	Name         string `xorm:"name"`
	Level        int32  `xorm:"level"`
	Type         string `xorm:"type"`
	ParentId     string `xorm:"parent_id"`
	Displayorder string `xorm:"displayorder"`
	Status       int32  `xorm:"status"`
}

func (s *Districts) TableName() string {
	return "districts"
}

type DistrictsRepository interface {
	InsertOne(doc *Districts) (id int64, err error)
	FindById(filter interface{}) (*Districts, error)
	FindFilter(str string, args ...interface{}) ([]*Districts, error)
}

//订单表相关
type Orders struct {
	OrderId        string    `xorm:"order_id"`
	Store_d        int32     `xorm:"store_id"`
	UserId         int32     `xorm:"user_id"`
	Username       string    `xorm:"username"`
	Mobile         string    `xorm:"mobile"`
	Address        string    `xorm:"address"`
	Body           string    `xorm:"body"`
	Detail         string    `xorm:"detail"`
	Attach         string    `xorm:"attach"`
	Total_fee      int32     `xorm:"total_fee"`
	Pay_at         time.Time `xorm:"pay_at"`
	Transaction_id string    `xorm:"transaction_id"`
	Pay_type       string    `xorm:"pay_type"`
	Pay_status     string    `xorm:"pay_status"`
	Created_at     time.Time `xorm:"created_at"`
	Updated_at     time.Time `xorm:"updated_at"`
}

func (s *Orders) TableName() string {
	return "orders"
}

type OrdersRepository interface {
	InsertOne(doc *Orders) (id int64, err error)
	FindById(filter interface{}) (*Orders, error)
	Sql(sql string) ([]*Orders, error)
}

//学校表相关
type Schools struct {
	Id        int32     `xorm:"id"`
	Name      string    `xorm:"name"`
	Province  int32     `xorm:"province"`
	City      int32     `xorm:"city"`
	Country   int32     `xorm:"country"`
	Address   string    `xorm:"address"`
	IsPrimary int32     `xorm:"is_primary"`
	IsMiddle  int32     `xorm:"is_middle"`
	CreatedAt time.Time `xorm:"created_at"`
	UpdatedAt time.Time `xorm:"updated_at"`
}

func (s *Schools) TableName() string {
	return "schools"
}

type SchoolsRepository interface {
	InsertOne(doc *Schools) (id int64, err error)
	FindById(filter interface{}) (*Schools, error)
	FindFilter(str string, args ...interface{}) ([]*Schools, error)
}

//订单中间表
type GoodsOrder struct {
	Id         int32     `xorm:"id"`
	GoodsId    int32     `xorm:"goods_id"`
	OrderId    string    `xorm:"order_id"`
	SchoolId   int32     `xorm:"school_id"`
	Class      string    `xorm:"class"`
	Total      int32     `xorm:"total"`
	Created_at time.Time `xorm:"created_at"`
	Updated_at time.Time `xorm:"updated_at"`
	Year       int32     `xorm:"year"`
	Type       int32     `xorm:"type"`
}

func (s *GoodsOrder) TableName() string {
	return "goods_order"
}

type GoodsOrderRepository interface {
	InsertOne(doc *GoodsOrder) (id int64, err error)
	FindById(filter interface{}) (*GoodsOrder, error)
}
